package models

import (
	"time"

	"gorm.io/gorm"
)

type Category struct {
	gorm.Model
	Id           int    `gorm:"column:id" json:"id"`
	CategoryName string `gorm:"column:category_name" json:"categoryName"`
	CreateTime   MyTime `gorm:"column:created_at" json:"createTime"`
	UpdateTime   MyTime `gorm:"column:updated_at" json:"updateTime"`
}
type CategoryVo struct {
	gorm.Model
	Id           int    `gorm:"column:id" json:"id"`
	CategoryName string `gorm:"column:category_name" json:"categoryName"`
	CreateTime   MyTime `gorm:"column:created_at" json:"createTime"`
	UpdateTime   MyTime `gorm:"column:updated_at" json:"updateTime"`
	ArticleCount int    `gorm:"column:article_count" json:"articleCount"`
}
type CategoryDto struct {
	gorm.Model
	Id           int    `gorm:"column:id" json:"id"`
	CategoryName string `gorm:"column:category_name" json:"categoryName"`
}
type SearchCategoryDto struct {
	CategoryName string `gorm:"column:category_name" json:"categoryName"`
	StartTime    MyTime `gorm:"column:start_time" json:"startTime"`
	EndTime      MyTime `gorm:"column:end_time" json:"endTime"`
}

func (table *Category) TableName() string {
	return "t_category"
}
func (table *CategoryVo) TableName() string {
	return "t_category"
}

func (table *CategoryDto) TableName() string {
	return "t_category"
}
func (table *Category) BeforeCreate(tx *gorm.DB) (err error) {
	table.CreateTime = MyTime(time.Now())
	table.UpdateTime = MyTime(time.Now())
	return
}
func (table *Category) BeforeUpdate(tx *gorm.DB) (err error) {
	table.UpdateTime = MyTime(time.Now())
	return
}